package apiday02;

import java.util.Scanner;

public class RegDemo11 {
    public static void main(String[] args) {
        /*
         *检查一个一个字符串是否为正确的IPv4地址
         * 正确IP：“192.168.1.25” “192.168.199.1 ”“10.0.0.20” "8.8.8.8"
         */
        //String reg = "\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}";
        String reg = "(\\d{1,3}\\.){3}\\d{1,3}";
        //String reg = "\\d{1,3}(\\.\\d{1,3}){3}";
        String s1 = "192.168.1.1";
        String s2 = "192-168-1-1";


        System.out.println(s1.matches(reg));
        System.out.println(s2.matches(reg));

/*        String reg1 = "\\d{1,3}\\.{3}\\d{1,3}";
        String s3 = "192...1";
        System.out.println(s3.matches(reg1));*/

/*        while(true){
            Scanner scan = new Scanner(System.in);
            String s3 = scan.nextLine();
            if(s3.matches(reg)){
                System.out.println("输入正确");
                break;
            }else{
                System.out.println("输入错误");
            }
        }*/


    }
}
